#ifndef DYN_PLANARBILLIARD_NEXTIMPACTFUNCTION_H
#define DYN_PLANARBILLIARD_NEXTIMPACTFUNCTION_H

#include <cmath>

#include "../utilities/dyn_functor.h"

/*! \author Joey Dumont <joey.dumont@gmail.com>
 *
 *  \date 2012-10-07
 *
 *  \brief Returns the straight-line trajectory of a billiard ball.
 *
 * Given an impact point, this function returns the proper
 * straight-line trajectory of a billiard ball hitting
 * a convex, closed billiard.
 */

class NextImpactFunction : public Functor
{
public:
    /*! The constructor needs the boundary, the impact
     * point and the direction of the ray. */
    NextImpactFunction(Functor& _boundary,
                       double _impactPoint=0.0,
                       double _direction=0.0);

    /*! @name Accessor Functions. */
    //@{
    Functor& getBoundary(){return boundary;}
    double getInputImpactPoint(){return impactPoint;}
    double getDirection(){return direction;}

    void setBoundary(Functor& _boundary){boundary=_boundary;}
    void setInputImpactPoint(double _impactPoint){impactPoint=_impactPoint;}
    void setDirection(double _direction){direction=_direction;}
    //@}

    double operator()(const double x);

protected:
    /*! @name Member variables. */
    Functor& boundary;
    double impactPoint,direction;
};

#endif // DYN_PLANARBILLIARD_NEXTIMPACTFUNCTION_H
